
#ifndef  STATE_H
#define  STATE_H

class LightsSystem;
class State {
public:
    State(int time);
    virtual ~State();

    virtual void start();
    virtual void stop();
    virtual void onTimeout(LightsSystem * ls);

    

protected:

    void onTimeout(LightsSystem * ls, State * nextState);

    virtual void on() = 0;
    virtual void off() = 0;

    int time(){ return _time;}
    int isEnd(){ return _leftTime == 0;}
    void elapse() { if(_leftTime > 0)  --_leftTime;}
    void reset() { _leftTime = _time;}


    void changeState(LightsSystem * ls, State * state);

private:
    int _time;
    int _leftTime;
};


#endif   /* STATE_H */
